<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sentinel 服务限流与熔断降级</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
        }
        .serif-font {
            font-family: 'Noto Serif SC', serif;
        }
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover:hover {
            transform: translateY(-4px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            padding: 1.5rem;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #667eea;
        }
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #e5e7eb, transparent);
            margin: 3rem 0;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-24">
        <div class="max-w-6xl mx-auto px-6">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 serif-font">
                    <i class="fas fa-shield-alt mr-4"></i>Sentinel 服务限流与熔断降级
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    构建稳定可靠的微服务架构防护体系
                </p>
                <div class="flex justify-center space-x-8 text-lg">
                    <div class="flex items-center">
                        <i class="fas fa-tachometer-alt mr-2"></i>
                        <span>流量控制</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-fire-extinguisher mr-2"></i>
                        <span>熔断降级</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-chart-line mr-2"></i>
                        <span>实时监控</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction Section -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-lg p-8 card-hover transition-all duration-300">
                <h2 class="text-3xl font-bold mb-6 gradient-text flex items-center">
                    <i class="fas fa-info-circle mr-3"></i>前言
                </h2>
                <div class="prose prose-lg max-w-none">
                    <p class="drop-cap text-gray-700 leading-relaxed">
                        在现代微服务架构中，服务的稳定性变得越来越重要。当系统资源不足，无法承载大量请求时，需要对系统按照一定的规则进行流量限制。如果不做流量控制，会导致系统资源占满、服务超时，在微服务体系中就有可能引起服务瘫痪和整体不可用的现象。
                    </p>
                </div>
            </div>
        </section>

        <!-- Sentinel Introduction -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-lg p-8">
                <h2 class="text-3xl font-bold mb-8 gradient-text flex items-center">
                    <i class="fas fa-shield-virus mr-3"></i>Sentinel 介绍
                </h2>
                
                <div class="grid md:grid-cols-2 gap-8 mb-8">
                    <div class="bg-gradient-to-br from-purple-50 to-pink-50 rounded-xl p-6">
                        <h3 class="text-xl font-semibold mb-4 text-purple-800">
                            <i class="fas fa-question-circle mr-2"></i>什么是 Sentinel？
                        </h3>
                        <p class="text-gray-700">
                            Sentinel 以流量为切入点，从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性，承接了阿里巴巴近 10 年的双十一大促流量的核心场景。
                        </p>
                    </div>
                    
                    <div class="bg-gradient-to-br from-blue-50 to-cyan-50 rounded-xl p-6">
                        <h3 class="text-xl font-semibold mb-4 text-blue-800">
                            <i class="fas fa-cogs mr-2"></i>核心功能
                        </h3>
                        <ul class="space-y-2 text-gray-700">
                            <li><i class="fas fa-check-circle text-green-500 mr-2"></i>流量控制</li>
                            <li><i class="fas fa-check-circle text-green-500 mr-2"></i>熔断降级</li>
                            <li><i class="fas fa-check-circle text-green-500 mr-2"></i>系统保护</li>
                            <li><i class="fas fa-check-circle text-green-500 mr-2"></i>实时监控</li>
                        </ul>
                    </div>
                </div>

                <!-- Features Grid -->
                <div class="grid md:grid-cols-2 lg:grid-cols-4 gap-6">
                    <div class="bg-gray-50 rounded-lg p-6 text-center card-hover transition-all duration-300">
                        <i class="fas fa-layer-group text-4xl text-purple-600 mb-4"></i>
                        <h4 class="font-semibold mb-2">丰富的应用场景</h4>
                        <p class="text-sm text-gray-600">秒杀、消息削峰填谷、集群流量控制等</p>
                    </div>
                    <div class="bg-gray-50 rounded-lg p-6 text-center card-hover transition-all duration-300">
                        <i class="fas fa-chart-area text-4xl text-blue-600 mb-4"></i>
                        <h4 class="font-semibold mb-2">完备的实时监控</h4>
                        <p class="text-sm text-gray-600">单机秒级数据、集群汇总运行情况</p>
                    </div>
                    <div class="bg-gray-50 rounded-lg p-6 text-center card-hover transition-all duration-300">
                        <i class="fas fa-puzzle-piece text-4xl text-green-600 mb-4"></i>
                        <h4 class="font-semibold mb-2">广泛的开源生态</h4>
                        <p class="text-sm text-gray-600">与 Spring Cloud、Dubbo 等框架整合</p>
                    </div>
                    <div class="bg-gray-50 rounded-lg p-6 text-center card-hover transition-all duration-300">
                        <i class="fas fa-plug text-4xl text-orange-600 mb-4"></i>
                        <h4 class="font-semibold mb-2">完善的 SPI 扩展</h4>
                        <p class="text-sm text-gray-600">简单易用的扩展接口，快速定制逻辑</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Architecture Diagram -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-lg p-8">
                <h2 class="text-3xl font-bold mb-8 gradient-text flex items-center">
                    <i class="fas fa-project-diagram mr-3"></i>Sentinel 架构体系
                </h2>
                <div class="mermaid">
                    graph TB
                        A[用户请求] --> B[Sentinel Client]
                        B --> C{流控规则判断}
                        C -->|通过| D[正常处理]
                        C -->|限流| E[限流处理]
                        B <--> F[Sentinel Dashboard]
                        F --> G[规则配置]
                        F --> H[实时监控]
                        B --> I[心跳上报]
                        I --> F
                        style A fill:#f9f,stroke:#333,stroke-width:2px
                        style F fill:#bbf,stroke:#333,stroke-width:2px
                        style D fill:#9f9,stroke:#333,stroke-width:2px
                        style E fill:#f99,stroke:#333,stroke-width:2px
                </div>
            </div>
        </section>

        <!-- Flow Control Rules -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-lg p-8">
                <h2 class="text-3xl font-bold mb-8 gradient-text flex items-center">
                    <i class="fas fa-traffic-light mr-3"></i>流控规则详解
                </h2>
                
                <div class="grid md:grid-cols-3 gap-6 mb-8">
                    <div class="bg-gradient-to-br from-red-50 to-orange-50 rounded-xl p-6">
                        <h3 class="text-xl font-semibold mb-4 text-red-700">
                            <i class="fas fa-bolt mr-2"></i>QPS 限流
                        </h3>
                        <p class="text-gray-700 mb-3">每秒最大请求数限制，超过阈值进行限流（外部限流）</p>
                        <div class="bg-white rounded-lg p-3 text-sm">
                            <code class="text-purple-600">阈值类型: QPS</code><br>
                            <code class="text-gray-600">适用场景: API 接口保护</code>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-br from-blue-50 to-indigo-50 rounded-xl p-6">
                        <h3 class="text-xl font-semibold mb-4 text-blue-700">
                            <i class="fas fa-users mr-2"></i>线程数限流
                        </h3>
                        <p class="text-gray-700 mb-3">调用接口的最大线程数，超过数量进行限流（内部限流）</p>
                        <div class="bg-white rounded-lg p-3 text-sm">
                            <code class="text-purple-600">阈值类型: 线程数</code><br>
                            <code class="text-gray-600">适用场景: 慢接口保护</code>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-br from-green-50 to-teal-50 rounded-xl p-6">
                        <h3 class="text-xl font-semibold mb-4 text-green-700">
                            <i class="fas fa-link mr-2"></i>关联限流
                        </h3>
                        <p class="text-gray-700 mb-3">当关联资源达到阈值时，限流当前资源</p>
                        <div class="bg-white rounded-lg p-3 text-sm">
                            <code class="text-purple-600">流控模式: 关联</code><br>
                            <code class="text-gray-600">适用场景: 资源竞争保护</code>
                        </div>
                    </div>
                </div>

                <!-- Flow Control Effects -->
                <div class="bg-gray-50 rounded-xl p-6">
                    <h3 class="text-2xl font-semibold mb-6 text-center">流控效果</h3>
                    <div class="grid md:grid-cols-3 gap-6">
                        <div class="text-center">
                            <i class="fas fa-hand-paper text-4xl text-red-500 mb-3"></i>
                            <h4 class="font-semibold mb-2">快速失败</h4>
                            <p class="text-sm text-gray-600">直接拒绝，抛出异常</p>
                        </div>
                        <div class="text-center">
                            <i class="fas fa-fire text-4xl text-orange-500 mb-3"></i>
                            <h4 class="font-semibold mb-2">Warm Up</h4>
                            <p class="text-sm text-gray-600">预热启动，缓慢增加</p>
                        </div>
                        <div class="text-center">
                            <i class="fas fa-hourglass-half text-4xl text-blue-500 mb-3"></i>
                            <h4 class="font-semibold mb-2">排队等待</h4>
                            <p class="text-sm text-gray-600">匀